import { request } from '../../request/index'

Page({

    /**
     * 页面的初始数据
     */
    data: {
        activeDetail: ''
    },
    // 报名按钮
    handleEnroll() {
        let _activeDetail = this.data.activeDetail
        request({
            url: '/xcxApi/enterpriseStoreActivityRecord/insert',
            data: {
                enterpriseStoreActivityId: _activeDetail.id,
                enterpriseStoreId: _activeDetail.enterpriseStoreId
            },
            method: 'post'
        }).then(res => {
            console.log('res:', res);
        })
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let _this = this
        const eventChannel = this.getOpenerEventChannel()
        eventChannel.on('sendData', function (data) {
            wx.setNavigationBarTitle({
                title: data.data.activityName
            });
            _this.setData({
                activeDetail: data.data
            })
            let url = `/pages/activityDetail/activityDetail&enterpriseStoreId=${  data.data.enterpriseStoreId }&enterpriseStoreActivityId=${ data.data.id }`
            let text = `会员进入活动—${ data.data.activityName }`
            request({
                url: '/xcxApi/enterpriseStoreActivityRecord/insertOoperationLog',
                method: 'post',
                data: {
                    url,
                    text
                }
            })
        })
        
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})